﻿// Copyright (c) MASA Stack All rights reserved.
// Licensed under the Apache License. See LICENSE.txt in the project root for license information.

namespace Masa.Auth.Contracts.Admin.Subjects;

public class UpdateThirdPartyIdpDto
{
    public Guid Id { get; set; }

    public string DisplayName { get; set; } = "";

    public string ClientId { get; set; } = "";

    public string ClientSecret { get; set; } = "";

    public string CallbackPath { get; set; } = "";

    public string AuthorizationEndpoint { get; set; } = "";

    public string TokenEndpoint { get; set; } = "";

    public string UserInformationEndpoint { get; set; } = "";

    public string Icon { get; set; } = "";

    public bool Enabled { get; set; } = true;

    public bool MapAll { get; set; }

    public Dictionary<string, string> JsonKeyMap { get; set; } = new();

    public UpdateThirdPartyIdpDto()
    {

    }

    public UpdateThirdPartyIdpDto(Guid id, string displayName, string clientId, string clientSecret, string callbackPath, string authorizationEndpoint, string tokenEndpoint, string userInformationEndpoint, string icon, bool enabled, bool mapAll, Dictionary<string, string> jsonKeyMap)
    {
        Id = id;
        DisplayName = displayName;
        ClientId = clientId;
        ClientSecret = clientSecret;
        CallbackPath = callbackPath;
        AuthorizationEndpoint = authorizationEndpoint;
        TokenEndpoint = tokenEndpoint;
        UserInformationEndpoint = userInformationEndpoint;
        Icon = icon;
        Enabled = enabled;
        MapAll = mapAll;
        JsonKeyMap = jsonKeyMap;
    }

    public static implicit operator UpdateThirdPartyIdpDto(ThirdPartyIdpDetailDto thirdPartyIdp)
    {
        return new UpdateThirdPartyIdpDto(thirdPartyIdp.Id, thirdPartyIdp.DisplayName, thirdPartyIdp.ClientId, thirdPartyIdp.ClientSecret, thirdPartyIdp.CallbackPath, thirdPartyIdp.AuthorizationEndpoint, thirdPartyIdp.TokenEndpoint, thirdPartyIdp.UserInformationEndpoint, thirdPartyIdp.Icon, thirdPartyIdp.Enabled, thirdPartyIdp.MapAll, thirdPartyIdp.JsonKeyMap);
    }
}
